import Vue from "vue";
import App from "./App.vue";
import router from "./router";
// 导入字体图标
import "./assets/font/iconfont.css";

// 在main.js中导入全局样式 可以全局生效
import "./assets/css/global.css";

// import "./plugins/element.js";

import axios from "axios";

import ZkTable from "vue-table-with-tree-grid";

//导入富文本编辑器
import VueQuillEditor from "vue-quill-editor";

// // 导入富文本对应的样式
// import "quill/dist/quill.core.css"; // import styles
// import "quill/dist/quill.snow.css"; // for snow theme
// import "quill/dist/quill.bubble.css"; // for bubble theme

// 导入上方进度条的第三方依赖
import NProgress from "nprogress";
// import "nprogress/nprogress.css";

axios.defaults.baseURL = "https://lianghj.top:8888/api/private/v1/";
//设置拦截器 再request拦截器中隐藏进度条 展示NProgress.start();

axios.interceptors.request.use((config) => {
  // console.log(config);
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
});
// 隐藏NProgress.done();
axios.interceptors.response.use((config) => {
  NProgress.done();
  return config;
});
// 注册第三方表格
Vue.use(ZkTable);

// 注册第三方富文本编辑器
Vue.use(VueQuillEditor);
// 处理时间的过滤器
Vue.filter("dateFormat", function (originValue) {
  const dt = new Date(originValue);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + "").padStart(2, "0");
  const d = (dt.getDate() + "").padStart(2, "0");
  const hh = (dt.getHours() + "").padStart(2, "0");
  const mm = (dt.getMinutes() + "").padStart(2, "0");
  const ss = (dt.getSeconds() + "").padStart(2, "0");
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
});

Vue.prototype.$http = axios;

Vue.config.productionTip = false;

new Vue({
  router,
  render: (h) => h(App),
}).$mount("#app");
